package com.tfswue.chy.config;

import org.springframework.cloud.client.ServiceInstance;
import org.springframework.cloud.loadbalancer.core.RandomLoadBalancer;
import org.springframework.cloud.loadbalancer.core.ServiceInstanceListSupplier;
import org.springframework.cloud.loadbalancer.support.LoadBalancerClientFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class MyConfig {
    @Bean
    public RandomLoadBalancer randomLoadBalancer(LoadBalancerClientFactory loadBalancerClientFactory){
        return new RandomLoadBalancer(loadBalancerClientFactory
                .getLazyProvider("user-server", ServiceInstanceListSupplier.class),
                "user-server");
    }
}
